package com.hongdee.market.car.report.controller;

import com.hongdee.base.entity.ResultEntity;
import com.hongdee.market.car.report.service.ITmCarReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zhangguokai
 * @desc 车辆等级报表查询
 */
@RestController
@RequestMapping("/market/car/level")
public class TmCarReportController {

    @Autowired
    private ITmCarReportService tmCarReportService;

    /***
     * 凯迪拉克- 车辆等级报表-查询
     * @param uid
     * @param token
     * @param start
     * @param limit
     * @param queryData
     * @return
     */
    @RequestMapping("/page")
    @ResponseBody
    public Map page(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token,
                    @RequestParam(name = "start", defaultValue = "0") String start,
                    @RequestParam(name = "limit", defaultValue = "50") String limit,
                    @RequestParam(name = "companyId", defaultValue = "") String companyId,
                    @RequestBody Map queryData) throws Exception {

        Map map = this.tmCarReportService.page(start, limit, queryData, companyId, uid);
        map.put("success", true);
        map.put("msg", "分页查询成功！");
        return map;
    }

    /**
     * @param uid
     * @param token
     * @param companyId
     * @param queryData
     * @return 查看饼状图
     * @throws Exception
     */
    @RequestMapping("/pie")
    @ResponseBody
    public ResultEntity pie(@RequestParam(name = "uid", defaultValue = "") String uid,
                            @RequestParam(name = "token", defaultValue = "") String token,
                            @RequestParam(name = "companyId", defaultValue = "") String companyId,
                            @RequestBody Map queryData) throws Exception {

        List ls = this.tmCarReportService.pie(queryData, companyId, uid);
        ResultEntity res = new ResultEntity();
        res.setDataList(ls);
        res.setSuccess(true);
        res.setMsg("查询成功");
        return res;
    }

    /**
     * @param uid
     * @param token
     * @param companyId
     * @param queryData
     * @return 查看柱状图与线状图
     * @throws Exception
     */
    @RequestMapping("/line")
    @ResponseBody
    public ResultEntity line(@RequestParam(name = "uid", defaultValue = "") String uid,
                             @RequestParam(name = "token", defaultValue = "") String token,
                             @RequestParam(name = "companyId", defaultValue = "") String companyId,
                             @RequestBody Map queryData) throws Exception {

        List ls = this.tmCarReportService.line(queryData, companyId, uid);
        ResultEntity res = new ResultEntity();
        res.setDataList(ls);
        res.setSuccess(true);
        res.setMsg("查询成功");
        return res;
    }

    /**
     * @param uid
     * @param token
     * @param companyId
     * @param vin
     * @return 等级提升建议
     * @throws Exception
     */
        @RequestMapping("/advise")
    @ResponseBody
    public ResultEntity advise(@RequestParam(name = "uid", defaultValue = "") String uid,
                               @RequestParam(name = "token", defaultValue = "") String token,
                               @RequestParam(name = "companyId", defaultValue = "") String companyId,
                               @RequestParam(name = "vin", defaultValue = "") String vin,
                               @RequestParam(name = "id", defaultValue = "") String id

    ) throws Exception {

        List ls = this.tmCarReportService.advise(vin, companyId, uid, id);
        ResultEntity res = new ResultEntity();
        res.setDataList(ls);
        res.setSuccess(true);
        res.setMsg("查询成功");
        return res;
    }
}
